﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.Presenter.UserAdminLogViewer;

namespace MS.InformationManagement.Controls._CONTROLTEMPLATES.InformationManagerControls
{
    public partial class UserAdminLogViewer : BaseControl, IUserAdminLogViewerView
    {
        #region [Private Fields]

        private UserAdminLogViewerPresenter _Presenter;

        #endregion

        #region [Event Handlers]

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _Presenter = new UserAdminLogViewerPresenter(this);
        }

        #endregion

        #region [IUserAdminLogViewerView Members]

        public int UserID
        {
            get
            {
                return ViewState["UserID"] == null ? 0 : Convert.ToInt32(ViewState["UserID"]);
            }
            set
            {
                ViewState["UserID"] = value;
            }
        }

        public System.Collections.Generic.IEnumerable<DAL.DocumentCenter.LogDeUsuario> LogEntries
        {
            get
            {
                return Cache["LogEntries"] as System.Collections.Generic.IEnumerable<DAL.DocumentCenter.LogDeUsuario>;
            }
            set
            {
                Cache["LogEntries"] = value;
                spgrdview.DataSource = value;
                spgrdview.DataBind();
            }
        }

        #endregion        

        #region [Public Members]

        public void LoadData() {
            if (UserID != 0)
            {
                _Presenter.HandleLoad();
            }
        }

        #endregion
    }
}
